<?php
MYTCONN();
$GET = $GLOBALS['MYT']->db_array("SELECT amh_ID AS O_ID, amh_Operacion AS COL5, amh_Fecha AS COL1, amh_Comentario COL2, 0 AS COL4, amh_levelid AS COL3, stt_Word AS COL6, amh_Reply AS COL7
  			FROM hd_amlalertas
				INNER JOIN hd_sysstatus ON sttFlag = amh_Status AND stt_Sistema = 14
			WHERE amh_CLIENT = {$_POST['CliNumero']}");
$CARD = $GET[0];
$SUM = 0;
$str = '';

for ($i = 1; $i <= $CARD; $i++) {
    $SUM += $GET[$i]['COL4'];
    $str .= "[$i,\"" . $GET[$i]['O_ID'] . "\",\"" . $GET[$i]['COL1'] . "\",\"" . trimall($GET[$i]['COL2']) . "\",\"" . $GET[$i]['COL3'] . "\",\"" . number_format($GET[$i]['COL4'], 2, ',', '') . "\",\"" . $GET[$i]['COL5'] . "\",\"" . $GET[$i]['COL6'] . "\",\"" . $GET[$i]['COL7'] . "\"],";
}
?>
<script charset="utf-8" type="text/javascript">
    disableSelection(document.getElementById("AMLList1"));

    Ext.onReady(function(){

        var myData = [<?php echo substr($str,0,strlen($str)-1);?>];

            var ds = new Ext.data.Store({
                reader: new Ext.data.ArrayReader({}, [
                    {name: 'id'},
                    {name: 'O_ID', type: 'int'},
                    {name: 'COL1', type: 'string'},
                    {name: 'COL2', type: 'string'},
                    {name: 'COL3', type: 'string'},
                    {name: 'COL4', type: 'string'},
                    {name: 'COL5', type: 'string'},
                    {name: 'COL6', type: 'string'},
                    {name: 'COL7', type: 'string'}
                ])
            });
            ds.loadData(myData);
            var colModel = new Ext.grid.ColumnModel([
                {header: "N", width: 40, sortable: true, locked:true, dataIndex: 'id'},
                {header: "Bloqueio", width: 60, sortable: true, locked:true, dataIndex: 'O_ID'},
                {header: "Remessa", width: 70, sortable: true, locked:true, dataIndex: 'COL5'},
                {header: "Data", width: 120, sortable: true, locked:true, dataIndex: 'COL1'},
                {header: "Comentario", width: 200, sortable: true, dataIndex: 'COL2'},
                {header: "Resposta", width: 200, sortable: true, dataIndex: 'COL7'},
                {header: "Nivel", width: 80, sortable: true, locked:true,dataIndex: 'COL3'},
                {header: "", width: 80, sortable: true, align:'right', locked:true,dataIndex: 'COL4'},
                {header: "Estado", width: 130, sortable: true, align:'right', locked:true,dataIndex: 'COL6'}
            ]);

            Bars = new Ext.Toolbar({

                store: this.store,
                height: 25,
                align: 'right',
                items : [ {
                        text: "# <?php echo $CARD; ?> | EUR: <?php echo number_format($SUM, 2); ?>"
                    } ]
            });

            var selmode = new Ext.grid.RowSelectionModel({});
            var Console = new Ext.grid.GridPanel({
                ds: ds,
                cm: colModel,
                sm: selmode,
                listeners: {
                    rowdblclick: function(ds, row) {
                        var record = ds.getStore().getAt(row);
                        var value = record.get('O_ID');
                        //ShowProp(value);
                    }
                },
                height: 300,
                border: true,
                bbar: Bars,
                renderTo: 'AMLList1'
            });

        });
</script>
<div id="AMLList1"></div>